package com.jwdf.uda.utils;

import android.annotation.TargetApi;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;

import com.jwdf.uda.R;

/**
 * 类说明：
 * 作者：huangqiuxin on 2016/5/27 21:01
 * 邮箱：648859026@qq.com
 */
public class ClipUtils {

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static boolean copy(Context context, String msg){
        boolean b = false;
        int version = Integer.valueOf(android.os.Build.VERSION.SDK);
        if(11 <= version){
            ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
            cmb.setText(msg);
            b = true;
        }else {
            android.text.ClipboardManager cmb = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
            cmb.setText(msg);
            b = true;
        }

        return b;
    }

    public static void copyContent(Context context,String content) {
        copy(context, StringUtils.filterNullAndTrim(content));
        ToastUtils.show(context, R.string.toast_copy_success);
    }

}
